package cn.xiaohuodui.util;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * Author :chenqisheng
 * Date   :15/10/15.
 * <p/>
 * 生成订单序列号
 */
public class OrderIdUtil {
    public static String genOrderNum(int orderId, int channel) {
        Random r = new Random();
        int r1 = (int) (r.nextInt(9));//产生2个0-9的随机数
        int r2 = (int) (r.nextInt(9));
        String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
        String sequ = new DecimalFormat("0000000").format(orderId);
        return date + channel + r1 + r2 + sequ;
    }
}
